package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MedicationMapper;
import com.ruoyi.system.domain.Medication;
import com.ruoyi.system.service.IMedicationService;

/**
 * 药品Service业务层处理
 *
 * @author ruoyi
 * @date 2023-02-14
 */
@Service
public class MedicationServiceImpl implements IMedicationService
{
    @Autowired
    private MedicationMapper medicationMapper;

    /**
     * 查询药品
     *
     * @param id 药品主键
     * @return 药品
     */
    @Override
    public Medication selectMedicationById(Long id)
    {
        return medicationMapper.selectMedicationById(id);
    }

    /**
     * 查询药品列表
     *
     * @param medication 药品
     * @return 药品
     */
    @Override
    public List<Medication> selectMedicationList(Medication medication)
    {
        return medicationMapper.selectMedicationList(medication);
    }

    /**
     * 新增药品
     *
     * @param medication 药品
     * @return 结果
     */
    @Override
    public int insertMedication(Medication medication)
    {
        medication.setCreateTime(DateUtils.getNowDate());
        return medicationMapper.insertMedication(medication);
    }

    /**
     * 修改药品
     *
     * @param medication 药品
     * @return 结果
     */
    @Override
    public int updateMedication(Medication medication)
    {
        medication.setUpdateTime(DateUtils.getNowDate());
        return medicationMapper.updateMedication(medication);
    }

    /**
     * 批量删除药品
     *
     * @param ids 需要删除的药品主键
     * @return 结果
     */
    @Override
    public int deleteMedicationByIds(Long[] ids)
    {
        return medicationMapper.deleteMedicationByIds(ids);
    }

    /**
     * 删除药品信息
     *
     * @param id 药品主键
     * @return 结果
     */
    @Override
    public int deleteMedicationById(Long id)
    {
        return medicationMapper.deleteMedicationById(id);
    }
}
